// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;
import KHD from "../TS/Message/KHD";

@ccclass
export default class LRcontr extends cc.Component {


    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
KHD.indl();
    }

    //登录
Load(){
 
//调用KHD.login
KHD.login(this.node.parent.getChildByName("account").getChildByName("TEXT_LABEL").getComponent(cc.Label).string,this.node.parent.getChildByName("passcount").getChildByName("TEXT_LABEL").getComponent(cc.Label).string)
}

HBFZ(){

this.node.parent.parent.getChildByName("大厅").active=true;
        //初始化大厅的角色名、货币
        console.log(KHD.HB[0])
        this.node.parent.parent.getChildByName("大厅").getChildByName("角色头像").getChildByName("Background").children[0].getComponent(cc.Label).string=KHD.Cname;
        this.node.parent.parent.getChildByName("大厅").getChildByName("货币").getChildByName("金币").getComponent(cc.Label).string=KHD.HB[0].toString()
        this.node.parent.parent.getChildByName("大厅").getChildByName("货币").getChildByName("钻石").getComponent(cc.Label).string=String(KHD.HB[1]);
        this.node.parent.parent.getChildByName("大厅").getChildByName("货币").getChildByName("猪币").getComponent(cc.Label).string=String(KHD.HB[2]);
        this.node.parent.active=false;
  
   
       
    }
    



    /*
    //原来的测试用户密码登录
    
    if(this.node.parent.getChildByName("account").getChildByName("TEXT_LABEL").getComponent(cc.Label).string=="1"&&this.node.parent.getChildByName("passcount").getChildByName("TEXT_LABEL").getComponent(cc.Label).string=="123456"){
        this.node.parent.parent.getChildByName("大厅").active=true;
        this.node.parent.active=false;
    }
    */


    // update (dt) {}


    Regis(){
        this.node.dispatchEvent(new cc.Event.EventCustom('rs',true));

    }

    Resgis1(){
        KHD.registered(this.node.parent.getChildByName("account").getChildByName("TEXT_LABEL").getComponent(cc.Label).string,
      
        this.node.parent.getChildByName("passcount").getChildByName("TEXT_LABEL").getComponent(cc.Label).string,
        this.node.parent.getChildByName("email").getChildByName("TEXT_LABEL").getComponent(cc.Label).string);
    }
    Rsback(){
        this.node.dispatchEvent(new cc.Event.EventCustom('rsb',true));

    }
}
